//
//  PlaylistViewCell.m
//  Kugou-OC
//
//  Created by BH on 16/5/12.
//  Copyright © 2016年 Sunny. All rights reserved.
//

#import "PlaylistViewCell.h"
#import "GlobalDefine.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>

@interface PlaylistViewCell (){
   
}

@end

@implementation PlaylistViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *identifier = @"PlaylistViewCell";
    PlaylistViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[PlaylistViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    
    return cell;
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor groupTableViewBackgroundColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, 55, 0, 10);
        
        _iconBtn = ALLOC(UIButton);
        _singName = ALLOC(UILabel);
        _singer = ALLOC(UILabel);
        _deleteBtn = ALLOC(UIButton);
        _favoriteBtn = ALLOC(UIButton);
        _downloadBtn = ALLOC(UIButton);
        
        [self.contentView sd_addSubviews:@[_iconBtn,_singer,_singName,_deleteBtn,_favoriteBtn,_downloadBtn]];
    }
    
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    _iconBtn.sd_layout.leftSpaceToView(self.contentView,15).topSpaceToView(self.contentView,10).bottomSpaceToView(self.contentView,10).widthEqualToHeight();
    [_iconBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _iconBtn.sd_cornerRadiusFromWidthRatio = @(0.5);
    
    _deleteBtn.sd_layout.rightSpaceToView(self.contentView,0).centerYEqualToView(self.contentView).heightIs(44).widthEqualToHeight();
    [_deleteBtn setImage:IMAGE(@"playlist_delete_btn") forState:UIControlStateNormal];
    
    _favoriteBtn.sd_layout.rightSpaceToView(_deleteBtn,0).topEqualToView(_deleteBtn).bottomEqualToView(_deleteBtn).widthEqualToHeight();
    [_favoriteBtn setImage:IMAGE(@"playlist_favorite") forState:UIControlStateNormal];
    
    _downloadBtn.sd_layout.rightSpaceToView(_favoriteBtn,0).topEqualToView(_favoriteBtn).bottomEqualToView(_favoriteBtn).widthEqualToHeight();
    [_downloadBtn setImage:IMAGE(@"playlist_download") forState:UIControlStateNormal];
    
    _singName.sd_layout.leftSpaceToView(_iconBtn,5).topEqualToView(_iconBtn).rightSpaceToView(_deleteBtn,5).autoHeightRatio(0);
    _singName.font = TITLE_THIRD_FONT;
    
    _singer.sd_layout.leftEqualToView(_singName).bottomEqualToView(_iconBtn).rightEqualToView(_singName).autoHeightRatio(0);
    _singer.font = TITLE_FOUR_FONT;
}



@end
